package com.ruis.kotboot.config.confs

import com.ruis.kotboot.common.core.BeanNames
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
import java.util.concurrent.ThreadPoolExecutor


//@Configuration
class SpringCommonBean: WebMvcConfigurer {

    @Bean(BeanNames.SPRING_THREADPOOL)
    @ConfigurationProperties(prefix = "springs.threadpool")
    fun druidDataSource(): ThreadPoolTaskExecutor {
        return ThreadPoolTaskExecutor().also {
            it.setRejectedExecutionHandler(ThreadPoolExecutor.CallerRunsPolicy())
        }
    }
}